package cc.wenshixin.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import cc.wenshixin.entity.Visit;

public class VisitDaoImpl extends BaseDaoImpl<Visit> implements VisitDao {

	@SuppressWarnings("all")
	@Override
	public List<Visit> selectMoreCondition(Visit visit) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		DetachedCriteria criteria = DetachedCriteria.forClass(Visit.class);
		if(visit.getAdminUser().getName() != null && !"".equals(visit.getAdminUser().getName())) {
			criteria.add(Restrictions.like("adminUser.name", "%"+visit.getAdminUser().getName()+"%"));
		}
		if(visit.getCustomer().getId() != null && visit.getCustomer().getId() > 0) {
			criteria.add(Restrictions.eq("customer.id", visit.getCustomer().getId()));
		}
		List<Visit> list = (List<Visit>) hibernateTemplate.findByCriteria(criteria);
		return list;
	}

	/*@Override
	public void add(Visit visit) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		hibernateTemplate.save(visit);
	}*/

	/*@SuppressWarnings("all")
	@Override
	public List<Visit> findAll() {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		List<Visit> list = (List<Visit>) hibernateTemplate.find("FROM Visit");
		return list;
	}*/

	/*@Override
	public Visit findOne(int id) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		Visit visit = hibernateTemplate.get(Visit.class, id);
		return visit;
	}*/

	/*@Override
	public void delete(Visit visit) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		hibernateTemplate.delete(visit);
	}*/

	/*@Override
	public void update(Visit visit) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		hibernateTemplate.update(visit);
	}*/

}
